package org.com.blbl.Gender;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
public class GenderMapper extends Mapper<Object,Text,Text,IntWritable>{
    private final static IntWritable one = new IntWritable(1);
    private Text gender = new Text();

    @Override
    public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
        String[] columns = value.toString().split(",");
        String genderValue = columns[5].trim();
        if (genderValue.equals("男") || genderValue.equals("女")) {
            gender.set(genderValue);
            context.write(gender, one);
        }
    }
}
